package com.amading.socket;


import com.amading.repository.ImMessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

//public class WebSocketConfig  {
//
//}

@Configuration
public class WebSocketConfig  implements WebSocketConfigurer {
    @Autowired
    private ImMessageRepository imMessageRepository;

    @Autowired
    private MyWebSocketHandler myWebSocketHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry
                .addHandler(myWebSocketHandler, "/ws").setAllowedOrigins("*"); // 允许所有源的WebSocket连接

    }
}
